import time
def sortbub(numbers):
    swap = True
    while swap:
        swap = False
        for i in range(len(numbers) - 1):
            if numbers[i] > numbers[i + 1]:
                numbers[i], numbers[i + 1] = numbers[i + 1], numbers[i]
                swap = True

def readfile(filename):
    file = open(filename, 'r')
    data = file.readlines()
    return data

m1 = readfile("m1_sorted.txt")
m2 = readfile("m2_reverse.txt")
m3 = readfile("m3_shuffle.txt")

start = time.time()
sortbub(m1)
finish = time.time()
print("m1_sorted", round((finish-start)*1000),"milliseconds")

start = time.time()
sortbub(m2)
finish = time.time()
print("m2_reverse", round((finish-start)*1000),"milliseconds")

start = time.time()
sortbub(m3)
finish = time.time()
print("m3_shuffle", round((finish-start)*1000),"milliseconds")
